package com.haiya.singleton.lazyman.threadsafe;

public class Singleton {
    private static Singleton singleton;

    private Singleton() {}

    /**
     *  当调用getInstance的时候才创建单例对象
     *
     *  为了解决线程不安全的问题，我们加入synchronized
     *  线程同步锁
     */
    public static synchronized Singleton getInstance() {
        if (singleton == null) {
            singleton = new Singleton();
        }
        return singleton;
    }
}